﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace NDI.Tests
{
    [TestClass]
    public class ServiceKeyFixture
    {
        [TestMethod]
        public void KeyEqualsByServiceAndFactoryType()
        {
            ServiceKey key1 = new ServiceKey(typeof(IFormatProvider), typeof(IFormattable));
            ServiceKey key2 = new ServiceKey(typeof(IFormatProvider), typeof(IFormattable));

            Assert.AreEqual(key1, key2);
            Assert.AreEqual(key1.GetHashCode(), key2.GetHashCode());
        }

        [TestMethod]
        public void KeyNotEqulasIfDiffServiceType()
        {
            ServiceKey key1 = new ServiceKey(typeof(object), typeof(IFormattable));
            ServiceKey key2 = new ServiceKey(typeof(IFormatProvider), typeof(IFormattable));

            Assert.AreNotEqual(key1, key2);
            Assert.AreNotEqual(key1.GetHashCode(), key2.GetHashCode());
        }

        [TestMethod]
        public void KeyNotEqualsIfDiffFactoryType()
        {
            ServiceKey key1 = new ServiceKey(typeof(IFormatProvider), typeof(object));
            ServiceKey key2 = new ServiceKey(typeof(IFormatProvider), typeof(IFormattable));

            Assert.AreNotEqual(key1, key2);
            Assert.AreNotEqual(key1.GetHashCode(), key2.GetHashCode());
        }

    }
}
